<template>
	<view class="page" :style="'height:' + height + 'rpx'">
		<view class="top" style="position: fixed; top: 0rpx;z-index: 1000;">
			<!-- 输入框 ——start -->
			<view class="input">
				<!-- <view class="iconfont icon-sousuo1"></view> -->
				<input style="z-index: 1000;" confirm-type="search" type="text" auto-blur @confirm="searchWare()"
					v-model="inputValue" :placeholder="inputPlaceholder"
					placeholder-style="padding-left: 20rpx;color: '#666666'" />
				<!-- 清空按钮  -start -->
				<view class="close" v-if="inputValue" @click="clearInput()">
					<view class="iconfont icon-guanbi"></view>
				</view>
				<!-- 清空按钮  -end -->
				<view class="iconfont icon-sousuo1" @click="searchWare()"></view>

				<!-- 提示词轮播  ——start-->
				<swiper class="place_swiper" autoplay interval=3000 circular vertical @change="placeChange"
					v-show="!focus">
					<swiper-item v-for="(item,index) in classifyList" :key="index">
						<view class="">{{item.type}}</view>
					</swiper-item>
				</swiper>
				<!-- 提示词轮播 ——end -->
			</view>
			<!-- 输入框 ——end -->

		</view>
		<view class="main" style="margin-top: 100rpx;">
			<view class="classify">
				<scroll-view scroll-y="true" style="z-index: 100;" :scroll-into-view="childrenId" scroll-with-animation>
					<view :class="{'classify_item': true, 'current_choose': (currentClassify === -1)}"
						@click="setClassify('',-1)" key="-1" id="id--1">
						<text class="left_border" v-show="currentClassify === -1"></text>
						<text style="font-size: 20rpx;" class="item_title">热门推荐</text>
					</view>
					<view @click="setClassify(item,index)" v-for="(item,index) in classifyList" :key="index"
						:class="{'classify_item': true, 'current_choose': (currentClassify === index)}"
						:id="'id-' + index">
						<text class="left_border" v-show="currentClassify === index"></text>
						<text class="item_title"
							:style="{'font-size': item.type.length > 2 ? '20rpx': '24rpx'}">{{item.type}}</text>
					</view>
				</scroll-view>
			</view>
			<scroll-view class="ware" style="z-index: 100;" scroll-y="true" lower-threshold="50"
				@scrolltolower="scrolltolower()" @scroll="scrollWare()" >
				<view class="list" v-if="!isFood && !noData">
					<wareItemRow v-if="currentClassify === -1" :isHot="true" class="list_item"
						v-for="(item2,index2) in hotList" :key="index2" :item="item2" @wareDetail="wareDetail()"
						@copyCode="copyCode()"></wareItemRow>
					<wareItemRow class="list_item wareItemRow" v-for="(item1,index1) in list" :key="index1"
						:item="item1" @wareDetail="wareDetail()" @copyCode="copyCode()"></wareItemRow>
				</view>
				<view v-if="isFood" class="isFood">
					<view class="food_item">
						<image src="http://1.14.247.152:9797/images/美团.jpg" show-menu-by-longpress="true"
							mode="aspectFit"></image>
					</view>
					<view class="food_item">
						<image :src="foodImage" show-menu-by-longpress="true" mode="aspectFit"></image>
					</view>


				</view>
				<view v-if="noData" class="noData">
					<view class="iconfont icon-wuanpai" style="color:#6B6B6B;margin-right: 25rpx;font-size: 45rpx;">
					</view>
					<view style="font-size: 45rpx;">暂无商品数据</view>
				</view>
				<view v-if="noMoreData" class="noMoreData">---暂无更多商品---</view>
				<view :class="loadingStyle" v-if="loading" :style="'padding-bottom:' + statusBarHeight + 'px'">
					<u-loading color="red" mode="semicircle" size="80"></u-loading>
					<view style="margin-left: 20rpx;" v-if="loadingBottom">正在加载中...</view>
					<view style="margin-left: 20rpx;" v-else>加载中...</view>
				</view>
			</scroll-view>
		</view>
		<!-- <tickTip ></tickTip> -->

		<!-- <view v-if="showWebView"> -->

		<!-- </view> -->
		<!-- 		<view class="bottom_tip">
			<view></view>
		</view> -->
		<!-- <view class="ticketTip" :style="'bottom:' + statusBarHeight + 'px;left:' + (screenWidth/4) + 'px;'">淘宝官方优惠券</view> -->
	</view>
</template>

<script>
	import wareItem from "../../components/wareItem/wareItem.vue"
	import wareItemRow from "../../components/wareItemRow/wareItemRow.vue";
	import tickTip from "../../components/tickTip/tickTip.vue";
	export default {
		async onLoad() {
			uni.hideLoading()
			// console.log('初始化')
			uni.showLoading({
				title: '加载中..',
				mask: true
			});
			this.height = getApp().globalData.pageHeight;
			this.header.Authority = uni.getStorageSync("Authority");
			this.windowHeight = wx.getSystemInfoSync().windowHeight;
			// console.log('窗口高度',this.windowHeight)
			this.getClassify();
			this.getTopWare()
			this.statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
			this.screenWidth = getApp().globalData.screenWidth;
			console.log(wx.getSystemInfoSync().statusBarHeight, 11111)

		},
		onShow() {
			let result = uni.getStorageSync('rebackFromGuanggao')
			// console.log(result,'结果')
			if (result) {
				uni.removeStorageSync('rebackFromGuanggao')
				uni.showLoading({
					title: '加载中..',
					mask: true
				});

				this.currentClassify = -1;
				// console.log('执行111')
				this.getQueryGoods(this.key, this.currentPage)

			}

			if (this.type === '外卖神券' || this.inputValue === '外卖神券') {

			}
			if (this.inputValue != '') {
				this.focus = true;
				this.inputPlaceholder = ''
			}

		},
		components: {
			wareItem,
			wareItemRow,
			tickTip
		},
		watch: {
			inputValue: {
				handler(newValue, oldValue) {
					// console.log(newValue,'新的值');
					if (newValue) {
						this.focus = true;
						this.inputPlaceholder = ''

					} else {
						this.focus = false;
						this.inputPlaceholder = ''

					}
				}
			}
		},
		onPullDownRefresh() {
			uni.showLoading({
				title: '加载中..',
				mask: true
			});

			if (this.type == '外卖神券' || this.inputValue == '外卖神券') {
				uni.hideLoading()
				uni.stopPullDownRefresh();
				return;
			}
			this.currentPage = 1;
			this.list = []
			if (this.isInput) {
				this.getQueryGoods(this.inputValue, this.currentPage, () => {
					uni.stopPullDownRefresh();
				});
			}
			if (this.currentClassify == -1) {
				this.getQueryGoods(this.key, this.currentPage, () => {
					uni.stopPullDownRefresh();
				});
			} else {
				this.getQueryGoods(this.type, this.currentPage, () => {
					uni.stopPullDownRefresh();
				});
			}
		},
		// onPageScroll: function (e) {
		// 	console.log(e.top)
		// 	    wx.createSelectorQuery().selectAll('.wareItemRow').boundingClientRect((ret) => {
		// 			console.log(ret,'数组')
		// 	     ret.forEach((item, index) => {
		// 			 console.log(item)
		// 	       // if (item.top <= height) { 判断是否在显示范围内
		// 	       //   group[index].show = true // 根据下标改变状态
		// 	       // }
		// 	     })
		// 	    }).exec()
		// },
		onHide() {
			// this.inputValue = ''
			getApp().globalData.toDetail = false;
			// console.log('进入详情页',getApp().globalData.toDetail)
		},
		data() {
			return {
				foodImage: '',
				screenWidth: 0, //屏幕宽度
				statusBarHeight: 0,
				height: 0,
				windowHeight: 0,
				inputPlaceholder: '',
				header: {
					Authority: ''
				},
				classifyList: [], //分类数组,里面是对象
				classifyValueList: [], //分类具体的数据
				currentClassify: -1,
				type: '', //当前商品类型
				currentPage: 1, //热门商品的页码
				list: [], //商品
				inputValue: '', //输入框的值
				noData: true, //无商品数据
				noMoreData: false, //没有更多数据

				focus: false, //是否聚焦
				currentSwip: '', //轮播文字当前显示
				loading: false, //是否显示loading图标
				loadingBottom: false, //是否是页面下方的加载
				key: '', //热门推荐关键字
				hotKey: '', //热门词
				hotList: [], //热门商品
				isFood: false, //当前类别是否为外卖神券
				isInput: false, //当前是否是输入框，用于下滑请求数据的
				// tempInput: '' //临时字符串保留输入的值
				code: '', //某一商品淘口令
				reachBottom: true,
				title: [], //商品标题
				count: 0, //翻了几次页
				lastLength: 0, //需要获取关键字的数据长度
				titleKey: [] //标题的关键字
				// showWebView: false
			}
		},
		computed: {
			loadingStyle() {
				if (this.loadingBottom) {
					// console.log('这个')
					return 'loadingBottom'
				} else {
					// console.log('loading')
					return 'loading'
				}
			}
		},
		methods: {
			async sendTitle(keyword, titleList) {
				let data = {
					keyword: '',
					titleList: []
				}
				data.keyword = keyword;
				data.titleList = titleList;
				// console.log('获取关键词参数，',data)
				let res = await getApp().UniRequest("/goods/getTenKeyWord", "POST", data, "");
				console.log('获取关键词', res)
				if (res.code === 20000) {
					this.titleKey = res.data.data;
					// console.log(this.titleKey)
				}
			},
			//显示图片
			showImage() {
				// console.log('下拉')
				wx.createSelectorQuery().selectAll('.wareItemRow').boundingClientRect((ret) => {
					// console.log(ret,'数组')
					ret.forEach((item, index) => {

						if (item.top <= (this.windowHeight)) {
							// item.show = true
							this.list[index].show = true
							// console.log(item,index)
						}
						// if (item.top <= height) { 判断是否在显示范围内
						//   group[index].show = true // 根据下标改变状态
						// }
					})
				}).exec()
			},
			copyCode(item) {
				// console.log('复制',item)
				this.code = ''
				uni.showLoading({
					title: '请稍等..',
					mask: true
				});
				uni.request({
					url: 'https://api.gzmiyuan.com/api/coupon/center/jsonp/getGenerate?itemSource=' + item
						.itemSource + '&itemSourceId=' + item.itemSourceId +
						'&itemTitle=' + item.itemTitle + '&itemDesc=' + item.itemDesc +
						'&itemPicture=' + item.itemPicture + '&itemPrice=' + item.itemPrice +
						'&couponPrice=' + item.couponPrice + '&itemVoucherPrice=' + item
						.itemVoucherPrice + '&saleMonth=' + item.saleMonth + '&couponUrl=' + item.couponUrl +
						'&inviteCode=YFRPEB',
					success: (res) => {
						// console.log(res.data, '淘口令');
						if (res.data.code === "B00000") {
							// console.log(res.data.data, '淘口令')
							this.code = res.data.data.tkl;

							// this.codeInfo = res.data.data.tkl;
							wx.setClipboardData({ //设置要复制的内容
								data: this.code, //这里是要复制的内容，可使用动态变量代替
								succese: (res) => {
									// console.log('设置复制内容成功', res);
									wx.getClipboardData({ //获取要复制的内容
										success: res => {
											// console.log('获取复制内容成功', res)
										}
									})
								}
							})

						}
						uni.hideLoading();
						uni.showModal({
							title: '提示',
							showCancel: false,
							content: '淘口令已复制，打开淘宝即可领取优惠券！',
							success: function(res) {
								if (res.confirm) {
									// console.log('用户点击确定');
								} else if (res.cancel) {
									// console.log('用户点击取消');
								}
							}
						});
						// this.clickMethod = true
					},
					fail(error) {
						// console.log('错误', error)
					}
				});
			},
			async getTopWare() {
				let res = await getApp().UniRequest("/goods/m/getTopKey", "Get", "", "");
				// console.log(res, '最热商品关键字')
				if (res.code === 20000) {
					// this.hotKey = res.data.data[0]
					// console.log('热词', res.data.data)
					res.data.data.forEach((item, index) => {
						this.hotKey = item;
						this.getHotGoods(this.hotKey, this.currentPage)
					})
					// console.log('指定数据',this.hotList)
				}
				// if (res.code === 20000) {
				// 	this.classifyList = res.data.data;

				// 	this.currentSwip = this.classifyList[0].type
				// 	console.log(this.classifyList)
				// 	this.classifyList.forEach((item, index) => {
				// 		this.classifyValueList.push(item.type)
				// 	})
				// 	// console.log(this.classifyList, '商品');
				// 	this.getHotList(this.currentPage)
				// } else {
				// 	uni.showToast({
				// 		title: '请稍后重试',
				// 		icon: 'error',
				// 		duration: 2000
				// 	});
				// }
			},

			//获取热门商品
			getHotGoods(hotKey, currentPage) {
				uni.request({
					url: 'https://api.gzmiyuan.com/api/goods/center/jsonp/search?itemSource=1&keywords=' +
						hotKey + '&searchType=1&coupon=1&page=' + currentPage +
						'&rows=10&sort=itemIndex&order=desc&supplierCode=&inviteCode=YFRPEB', //仅为示例，并非真实接口地址。

					success: (res) => {
						// console.log(res.data, '蜜源数据');
						if (res.data.code == "B00000") {
							let item = res.data.data.data[0]
							// console.log(res.data.data.data, '置顶数据');
							let newPrice = item.itemVoucherPrice;
							let oldPrice = item.itemPrice;
							let down = oldPrice - newPrice;
							if (down >= 0) {
								item.ticket = down.toFixed(1)
							} else {
								item.ticket = 0
							}
							item.show = true
							this.hotList.push(item)
						}

					},
					fail(error) {
						// console.log('错误', error)
					}
				});
			},

			//获取主页关键字
			async getKey() {
				let res = await getApp().UniRequest("/goods/m/authority/getListKey", "Get", "", this
					.header);
				// console.log('主页关键字', res)
				if (res.code === 20000) {
					this.key = res.data.data[0].titleLike;
					// console.log(this.key, 111)
					// console.log(this.key, '热门推荐')
					//初始化数据

					this.getQueryGoods(this.key, this.currentPage)
				}
			},

			//获取分类
			async getClassify() {
				// uni.showLoading({
				// 	title: '请稍等..',
				// 	mask: true
				// });
				let res = await getApp().UniRequest("/goods/m/authority/getType", "Get", "", this
					.header);
				console.log(res.data.data)
				if (res.code === 20000) {
					this.classifyList = res.data.data;

					this.currentSwip = this.classifyList[0].type
					// console.log(this.classifyList)
					this.classifyList.forEach((item, index) => {
						this.classifyValueList.push(item.type)
					})
					// console.log(this.classifyList, '商品');
					// this.getHotList(this.currentPage)
					// this.childrenId = 'id-18'
					// console.log(this.childrenId)
					this.getKey()

				} else {
					uni.showToast({
						title: '请稍后重试',
						icon: 'error',
						duration: 2000
					});
				}
			},

			//设置分类
			async setClassify(item, index) {
				this.focus = false;
				// uni.showLoading({
				// 	title: '加载中..',
				// 	mask: true
				// });
				this.loadingBottom = false;
				this.loading = true
				// console.log('执行', item, index)

				//初始化数据

				this.list = [];
				this.currentPage = 1;
				this.noMoreData = false;
				this.inputValue = '';
				this.isFood = false;
				this.noData = false;
				this.isInput = false;
				this.count = 0

				this.currentClassify = index;
				this.type = item.type;


				// console.log(this.type)
				if (index === -1) {
					// console.log('获取热门商品');
					this.getQueryGoods(this.key, this.currentPage)
				} else if (this.type === "外卖神券") {
					this.noData = false;
					this.noMoreData = false;

					//
					let num = Math.round(Math.random()); //获取随机数为 0 / 1
					// console.log(num)
					if (num) {
						// this.showShadow = true;
						this.foodImage = 'http://1.14.247.152:9797/images/饿了么.jpg'

					} else {
						this.foodImage = 'http://1.14.247.152:9797/images/（旧）饿了么.jpg'
					}
					this.isFood = true
					uni.hideLoading();
					this.loading = false
				} else if (this.type === "百万饭补") {
					// this.showWebView = true
					uni.navigateTo({
						url: '../../page_ware/guangGao/guangGao'
					});
				} else {

					this.getQueryGoods(this.type, this.currentPage)
				}
				if (index != -1) {
					let id = ""
					this.classifyList.forEach((item, index) => {
						if (item.type == this.type) {
							// console.log(this.type,item,111);
							id = item.id;
						}
					})
					let res = await getApp().UniRequest("/goods/m/authority/clickType?typeId=" + id, "Get", "", this
						.header);
					console.log('插入"点击左侧列表的类别"信息', res)
				}

			},

			//获取热门商品
			async getHotList(currentPage, callback) {
				// console.log('页码', this.currentPage)
				// let res = await getApp().UniRequest("/goods/getList?currentPage=" + currentPage, "Get", "",
				// 	this
				// 	.header);
				// console.log(res, '热门商品')
				// if (res.code === 20000) {
				// 	if (res.data.data.length === 0 && this.list.length != 0) {
				// 		this.noMoreData = true
				// 	} else {
				// 		//有数据
				// 		this.noData = false
				// 		this.list.push(...this.dataChange(res.data.data));
				// 	}
				// 	if (this.list.length === 0) {
				// 		this.noData = true
				// 	}
				// 	console.log(this.list);
				// 	this.loading = false
				// 	uni.hideLoading();
				// 	callback && callback()
				// }
			},
			async getQueryGoods(content, currentPage, callback) {
				// console.log('参数',content,currentPage)
				uni.request({
					url: 'https://api.gzmiyuan.com/api/goods/center/jsonp/search?itemSource=1&keywords= ' +
						content + '&searchType=1&coupon=1&page=' + currentPage +
						'&rows=20&sort=&order=&supplierCode=&inviteCode=YFRPEB', //仅为示例，并非真实接口地址。

					success: (res) => {
						// console.log(res.data, currentPage, '蜜源数据');
						if (res.data.code == "B00000") {

							this.isFood = false;
							this.reachBottom = true

							//加载更多时出现的情况
							if (res.data.data.data.length === 0 && this.list.length != 0) {
								this.noMoreData = true
							} else {
								//有数据
								this.noData = false
								this.list.push(...this.dataChange(res.data.data.data));
								// if (this.currentPage == 1) {
								// 	this.showImage()
								// }
							}

							//一条数据都没有
							if (this.list.length === 0) {
								this.noData = true
							}
							// console.log(this.count)
							this.count++;
							if (this.count === 1) {
								this.lastLength = this.dataChange(res.data.data.data).length;
								console.log('数据长度',this.lastLength)
							}

							//每1、28、55页时重置title，并发起请求
							if (this.count % this.lastLength === 1) {
								// console.log(this.count,'title数组要加值');
								this.title = [];
								this.count = 1;
								console.log( this.lastLength,this.list)
								for (let i = 0; i < this.lastLength; i++) {
									this.title.push(this.list[i].itemTitle);
								}
								this.sendTitle(content, this.title)
								// console.log(this.title,'标题数组')
							}

							// console.log(this.list)
							uni.hideLoading();
							this.loading = false
							callback && callback()
						}

					},
					fail(error) {
						// console.log('错误', error)
					}
				});

			},


			//获取分类商品
			// async getQueryGoods(content, currentPage, callback) {
			// 	// let res = await getApp().UniRequest("/goods/queryGoods?content=" + content +
			// 	// 	'&currentPage=' +
			// 	// 	currentPage, "Get", "", this
			// 	// 	.header);
			// 	// console.log(res)
			// 	// if (res.code === 20000) {
			// 	// 	if (res.data.data.length === 0 && this.list.length != 0) {
			// 	// 		this.noMoreData = true
			// 	// 	} else {
			// 	// 		//有数据
			// 	// 		this.noData = false
			// 	// 		this.list.push(...this.dataChange(res.data.data));
			// 	// 	}

			// 	// 	if (this.list.length === 0) {
			// 	// 		this.noData = true
			// 	// 	}

			// 	// 	console.log(this.list)
			// 	// 	uni.hideLoading();
			// 	// 	this.loading = false
			// 	// 	callback && callback()
			// 	// } else {
			// 	// 	console.log(res)
			// 	// }
			// 	// console.log('参数', currentPage, content)

			// 		// console.log('执行')
			// 		uni.request({
			// 			url:  'https://api.gzmiyuan.com/api/goods/center/jsonp/search?itemSource=1&keywords= '+ content  + '&searchType=1&coupon=1&page=' + currentPage + '&rows=20&sort=&order=&supplierCode=&inviteCode=YFRPEB', //仅为示例，并非真实接口地址。

			// 			success: (res) => {
			// 				console.log(res.data, currentPage, '蜜源数据');
			// 				if (res.data.code == "B00000") {
			// 					this.isFood = false;
			// 					this.reachBottom = true

			// 					//加载更多时出现的情况
			// 					if (res.data.data.data.length === 0 && this.list.length != 0) {
			// 						this.noMoreData = true
			// 					} else {
			// 						//有数据
			// 						this.noData = false
			// 						this.list.push(...this.dataChange(res.data.data.data));
			// 						// if (this.currentPage == 1) {
			// 						// 	this.showImage()
			// 						// }
			// 					}

			// 					//一条数据都没有
			// 					if (this.list.length === 0) {
			// 						this.noData = true
			// 					}

			// 					// console.log(this.list)
			// 					uni.hideLoading();
			// 					this.loading = false
			// 					callback && callback()
			// 				}

			// 			},
			// 			fail(error) {
			// 				// console.log('错误', error)
			// 			}
			// 		});

			// },

			//对商品数据进行处理
			dataChange(data) {
				let result = []
				data.forEach((item, index) => {
					if (item.itemTitle == null || item.itemVoucherPrice == null || item.itemPrice == null || item
						.sellerName == null) {

					} else {
						// console.log(item)
						let newPrice = item.itemVoucherPrice;
						let oldPrice = item.itemPrice;
						let down = oldPrice - newPrice;
						if (down >= 0) {
							// item.couponPrice = down.toFixed(1)
							item.ticket = down.toFixed(1)
						} else {
							item.ticket = 0;
							// item.couponPrice = 0
							item.itemVoucherPrice = item.itemPrice
						}
						if (this.currentPage == 1) {
							item.show = true
						} else {
							item.show = false
						}
						// console.log(item.couponPrice )

						// console.log(item.itemBanner[0])
						// //对图片数据处理，若图片地址错误更换为替代图片
						uni.getImageInfo({
							src: item.itemPictureMax,
							success: function(image) {},
							fail(error) {
								console.log('错误信息', error)
								item.itemPictureMax = 'http://1.14.247.152:9797/images/nopic.png'
							}
						});
						// uni.getImageInfo({
						// 	src: item.itemBanner[0],
						// 	success: function(image) {},
						// 	fail(error) {
						// 		console.log('错误信息', error)
						// 		item.itemBanner[0] = 'http://1.14.247.152:9797/images/nopic.png'
						// 	}
						// });
						result.push(item);
					}


				})
				return result;
			},
			scrollWare() {
				this.showImage()
			},

			//商品到达页面底部
			scrolltolower() {
				if (this.reachBottom) {
					this.reachBottom = false;
					//当前情况没有数据了，就不用再发请求了
					if (this.noMoreData) {
						// console.log('已无更多数据')
					} else {
						if (this.type === '外卖神券') {

							return;
						}

						this.loadingBottom = true
						this.loading = true;
						// if (this.count === this.lastLength)
						if (this.isInput) {
							console.log('执行', this.count)
							this.getQueryGoods(this.titleKey[this.count - 1], 1);
							// console.log(this.titleKey[this.count - 1])
							// this.count++;
						} else if (this.currentClassify === -1) {
							// this.getHotList(this.currentPage++);
							// console.log('执行111',this.currentPage)
							// this.currentPage = this.currentPage + 1;
							// console.log('执行111',this.currentPage)
							// console.log('执行',this.count)
							this.getQueryGoods(this.titleKey[this.count - 1], 1);
							// console.log(this.titleKey[this.count - 1])
							// this.count++;
							// console.log(this.currentPage)
						} else {
							this.getQueryGoods(this.titleKey[this.count - 1], 1);
							// console.log(this.titleKey[this.count - 1])
							// this.count++;
						}
					}
				}


			},

			//搜索商品
			async searchWare() {
				uni.showLoading({
					title: '加载中..',
					mask: true
				});
				this.isInput = true

				//初始化数据
				this.currentPage = 1;
				this.list = [];
				this.noMoreData = false;
				// this.inputValue = '';
				this.isFood = false;
				this.noData = false;
				this.type = "";
				this.count = 0

				//定义搜索参数
				let inputValue = '' //由于搜索框中不一定有值，所以搜索参数不一定时this.inputValue
				if (this.inputValue) {

				} else {
					this.inputValue = this.currentSwip
					this.focus = true;
					// this.tempInput = this.currentSwip;
				}

				console.log('输入框的值', this.inputValue)
				if (this.inputValue === "外卖神券") {
					this.noData = false;
					this.noMoreData = false;
					this.isFood = true
					uni.hideLoading();
					this.loading = false;
					this.currentClassify = this.classifyValueList.indexOf("外卖神券")
					return;
				}
				if (this.inputValue === "百万饭补") {
					uni.navigateTo({
						url: '../../page_ware/guangGao/guangGao'
					});
					return;
				}
				// console.log('执行')
				//当输入框的值刚好为分类
				if ((this.classifyValueList.indexOf(this.inputValue) != -1) || (this.inputValue == '热门推荐')) {
					// console.log('刚好是当前分类');
					if (this.inputValue == '热门推荐') {
						this.currentClassify = -1;
						// this.getHotList(this.currentPage);
						this.getQueryGoods(this.key, this.currentPage);
						return;
					} else {
						// console.log(this.classifyValueList.indexOf(this.inputValue))
						this.currentClassify = this.classifyValueList.indexOf(this.inputValue)
					}

				} else {
					//不是分类，分类栏不高亮
					this.currentClassify = -2
				}
				console.log(this.inputValue, '数据')
				this.getQueryGoods(this.inputValue, this.currentPage);
				let res = await getApp().UniRequest("/goods/m/authority/insertSearchInfo?content=" + this.inputValue,
					"Get", "", this
					.header);
				// console.log(res,'插入搜索结果')
			},

			//清空搜索
			clearInput() {
				uni.showLoading({
					title: '请稍等..',
					mask: true
				});
				this.inputValue = '';
				this.inputPlaceholder = '';
				this.focus = false;
				this.currentClassify = -1;
				// this.getHotList()
				this.currentPage = 1;
				// this.getQueryGoods(this.type, this.currentPage);
				this.list = [];
				this.currentPage = 1;
				this.noMoreData = false;
				this.inputValue = '';
				this.isFood = false;
				this.noData = false;
				this.isInput = false;
				this.getKey()
			},


			//轮播文字改变
			placeChange(event) {
				// console.log(event.detail);
				this.currentSwip = this.classifyList[event.detail.current].type
				// console.log('轮播图改变',this.currentSwip )
			},

			//聚焦事件
			inputFocus() {
				// if (this.inputValue) {

				// } else {
				// 	console.log('聚焦')
				// 	this.inputPlaceholder = this.currentSwip
				// 	this.focus = true;
				// 	this.tempInput = this.currentSwip;
				// }
			},

			//失去焦点
			inputBlur() {
				// if (this.inputValue) {

				// } else {
				// 	this.inputPlaceholder = ''
				// 	this.focus = false;
				// }				
			},

			//用户输入
			haveInput() {

			},


			//点击搜索
			// clickSearch() {
			// 	// this.focus = true;
			// 	// this.inputValue = this.currentSwip;
			// 	// console.log('搜索条件',this.inputValue )
			// 	// this.searchWare();
			// 	// this.inputValue = ''
			// 	// this.focus = false
			// 	if (this.inputValue) {

			// 	} else {
			// 		this.inputValue = this.currentSwip
			// 		this.focus = true;
			// 		this.tempInput = this.currentSwip;
			// 	}
			// 	this.searchWare()
			// },

			//去商品详情页
			wareDetail(item) {
				if (!getApp().globalData.toDetail) {
					// console.log('值')
					getApp().globalData.toDetail = true
					// this.focus = false;
					// console.log(item)
					let details = {}
					details.itemSourceId = item.itemSourceId;
					details.itemDesc = item.itemDesc;
					details.ticket = item.ticket;

					let Range = this.titleKey.length - 1;
					console.log('范围',Range)
					let Rand = Math.random();
					let num = Math.floor(Rand * Range); //舍去
					console.log(num,'随机数')
					details.content = this.titleKey[num];
					console.log('搜索数据',details.content)

						let id = item.id;
					uni.navigateTo({
						url: '../../page_ware/wareDetail/wareDetail?item=' + JSON.stringify(details)
					});
				}

			},

			//图片错误
			imageError() {
				// console.log('图片错误', e)
			}


		}
	}
</script>

<style lang="scss" scoped>
	* {
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}

	.page {
		position: relative;
		padding-bottom: 30rpx;
		padding-right: 10rpx;
		overflow: hidden;

		.ticketTip {
			position: fixed;
		}

		.bottom_tip {
			width: 200rpx;
			height: 100rpx;
			background-color: pink;
			position: fixed;
			bottom: 0rpx;
		}

		.top {
			width: 100%;
			height: 100rpx;
			background-color: #23B8FF;
			position: relative;


			.input {
				position: absolute;
				width: 90%;
				height: 70rpx;
				display: flex;
				top: 50%;
				left: 50%;
				margin-left: -45%;
				margin-top: -35rpx;
				padding-left: 20rpx;
				border-radius: 40rpx;
				background-color: #FFFFFF;
				line-height: 70rpx;

				.place_swiper {
					position: absolute;
					left: 40rpx;
					z-index: 100;
					width: 500rpx;
					height: 70rpx;
					line-height: 70rpx;
					// background-color: pink;
					color: #666666;

					.swiper-item {
						width: 100%;
						height: 100%;
					}
				}

				.close {
					z-index: 1100;
					position: absolute;

					width: 35rpx;
					height: 35rpx;
					right: 17%;
					top: 50%;
					margin-top: -17.5rpx;
					border-radius: 50%;
					background-color: pink;
					// position: absolute;
					background: rgba(0, 0, 0, 0.3);
					line-height: 35rpx;
					text-align: center;

					.iconfont {
						font-size: 24rpx;
						font-weight: 700;
						color: #E0FFFF;
					}
				}

				.icon-sousuo1 {
					width: 16%;
					background-color: #F0F8FF;
					border-top-right-radius: 40rpx;
					border-bottom-right-radius: 40rpx;
					text-align: center;
					font-size: 40rpx;
					font-weight: 700;
					color: #23b8ff;
				}

				input {
					width: 90%;
					height: 100%;
					// padding-left: 20rpx;
				}
			}
		}

		.main {
			width: 100%;
			height: 100%;
			display: flex;
			margin-top: 10rpx;
			position: relative;


			.classify {
				width: 15%;
				height: 100%;
				background-color: #f2f2f2;

				scroll-view {
					text-align: center;
					height: 100%;

					.classify_item {
						position: relative;
						height: 85rpx;
						line-height: 85rpx;
						font-size: 22rpx;
						background-color: #f2f2f2f2;
						letter-spacing: 2rpx;
						text-overflow: ellipsis;
						white-space: nowrap;
						overflow: hidden;

						.left_border {
							width: 8rpx;
							height: 50rpx;
							position: absolute;
							left: 10rpx;
							top: 50%;
							margin-top: -25rpx;
							background-color: #23B8FF;
							border-radius: 10rpx;
						}

						.item_title {
							margin-left: 14rpx;
							padding: 5rpx;
						}
					}

					.current_choose {
						background-color: #ffffff;
						font-weight: 700;
					}
				}
			}

			.ware {
				width: 85%;
				height: 100%;
				position: relative;
				z-index: 1000;
				// padding-bottom: 20rpx;

				// background-color: #F29100;
				.list {
					padding: 0rpx 0rpx 20rpx 20rpx;
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;
					width: 100%;
					// background-color: #eff1ec;

					.list_item {
						width: 100%;
						height: 260rpx;
						background-color: #ffffff;
						// margin-bottom: 30rpx;
						// border-radius: 20rpx;
						// padding-bottom: 10rpx;

					}

					&>.list_item:nth-child(1),
					&>.list_item:nth-child(2) {
						margin-top: 20rpx;
					}

				}

				.isFood {
					width: 100%;

					.food_item {
						width: 95%;
						margin: 0 auto;
						// margin-top: 30rpx;
						box-shadow: 1rpx 1rpx 20rpx #EEE9E9;
						margin-top: 60rpx;

						image {
							// width: 100%;
						}
					}

				}

				.noData {
					height: 150rpx;
					width: 650rpx;
					line-height: 50rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					position: absolute;
					top: 50%;
					margin-top: -150rpx;
					left: 50%;
					margin-left: -325rpx;
					font-size: 50rpx;
					color: #6B6B6B;
					// background-color: #fff;
					// box-shadow: 0.5rpx 0.5rpx 40rpx #DBDBDB;
					border-radius: 20rpx;
				}

				.ware_item {
					display: flex;
					height: 260rpx;
					padding: 10rpx;

					// background-color: #F29100;
					.ware_image {
						width: 40%;
						height: 100%;
						padding: 10rpx;
						padding-right: 20rpx;

						image {
							width: 100%;
							height: 100%;
							border-radius: 10rpx;
						}
					}

					.ware_detail {
						width: 65%;
						// height: 100%;
						// padding-bottom: 20rpx;
						border-bottom: 1rpx solid #DBDBDB;

						.detail_title {
							// height: 80rpx;
							line-height: 42rpx;
							// background-color: pink;
							letter-spacing: 3rpx;
							font-weight: 700;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							overflow: hidden;
							-webkit-box-orient: vertical;
						}

						.detail_ticket {
							display: inline-block;
							// width: 120rpx;
							height: 40rpx;
							background-color: #FF6347;
							color: #FFFFFF;
							margin-top: 10rpx;

							line-height: 40rpx;

							.ticket_box {
								width: 100%;
								font-size: 20rpx;
								height: 100%;
								position: relative;
								padding-left: 10rpx;
								padding-right: 10rpx;

								.dotted {
									position: absolute;
									left: 44rpx;
									top: 50%;
									margin-top: -12.5%;
									width: 2rpx;
									height: 70%;
									background-color: #DBDBDB;
								}

								.tick_cicle {
									position: absolute;
									width: 14rpx;
									height: 14rpx;
									top: 50%;
									margin-top: -7rpx;
									border-radius: 50%;
									background-color: #FFFFFF;
								}

								.left_cicle {

									left: -10rpx;
								}

								.right_cicle {
									right: -10rpx;

								}

								text {
									display: inline-block;
									text-align: center;

								}

							}
						}

						.detail_price {
							margin-top: 10rpx;
							height: 50rpx;
							line-height: 50rpx;

							// background-color: pink;
							.cerrent_price {
								color: #EE4000;
								font-weight: 700;
							}

							.old_price {
								margin-left: 10rpx;
								font-weight: 500;
								font-size: 24rpx;
								text-decoration: line-through;
								color: #949494;
							}
						}

						.bottom {
							padding-top: 10rpx;
							padding-bottom: 20rpx;
							margin-top: 10rpx;
							height: 40rpx;
							line-height: 40rpx;
							// background-color: pink;
							display: flex;
							justify-content: space-between;
							align-items: center;
							color: #949494;
							font-size: 24rpx;

							// background-color: pink;
							.bottom_left {
								width: 55%;

								.detail_local {
									width: 100%;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;

								}
							}

							.bottom_right {
								width: 45%;
								text-align: right;
								padding-right: 10rpx;
							}
						}
					}
				}

				.loading {
					display: flex;
					position: absolute;
					left: 50%;
					top: 35%;
					width: 300rpx;
					height: 200rpx;
					line-height: 200rpx;
					font-size: 38rpx;
					margin-top: -100rpx;
					margin-left: -150rpx;
					// background-color: pink;
					color: #666666;

				}

				.loadingBottom {
					width: 100%;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 34rpx;
					color: #666666;
				}

				.noMoreData {
					text-align: center;
					font-size: 24rpx;
					color: #6B6B6B;
				}

			}
		}

		.likeTitle {
			margin-top: 40rpx;
			width: 100%;
		}
	}
</style>
